package com.qcby.demo.proxyaop.reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @className: RefectTest
 * @description:
 * @author: lxt
 * @create: 2021-05-13 16:06
 **/
public class RefectTest {

    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        Hello hello = new Hello();
        say(hello);
    }

    public static void say(Hello hello) throws InvocationTargetException, IllegalAccessException, ClassNotFoundException, NoSuchMethodException {
        // 获取class对象
        Class clz = Class.forName("com.qcby.demo.proxyaop.reflect.Hello");
        Method method = clz.getMethod("say");
        System.out.println("快见面了");
        method.invoke(hello);
        System.out.println("见面结束了");
    }
}
